﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Collections.Specialized;

namespace NWN.GDY.Service.Common
{
    public static class GDYConfig
    {
        private static NameValueCollection _settings = null;

        private static NameValueCollection Settings
        {
            get { return GDYConfig._settings; }
            set { GDYConfig._settings = value; }
        }


        private static string Get(this string key, string defaultValue)
        {
            return GetConfig(key, defaultValue);
        }

        private static string GetConfig(string key, string defaultValue)
        {
            if (_settings == null)
                _settings = ConfigurationManager.AppSettings;
            if (_settings[key] != null)
            {
                return _settings[key];
            }
            else
                return defaultValue;
        }

        #region 缓存
        /// <summary>
        /// CacheRoomList
        /// </summary>
        public static int CacheRoomList
        {
            get
            {
                int result = 60;
                if (!int.TryParse(GetConfig("CacheRoomList", @"60"), out result)) result = 60;
                return result;
            }
        }
        #endregion

    }
}
